package com.jams.goodox.utils;

import android.content.Context;

import com.jams.goodox.BaseActivity;
import com.jams.goodox.listen.ActionResultListener;
import com.jams.goodox.listen.SuccessListener;
import com.jams.goodox.net.BaseEntity;
import com.jams.goodox.net.RetrofitCallbackListener;
import com.jams.goodox.net.services.RentingService;

import retrofit2.Call;

/**
 * Created by jams on 2016/8/9.
 * ***
 * Tel: ***
 * 点赞，取消点赞；报名，取消报名;评论
 */

public class CircleManager {

    //点赞等操作
    public static void praise(final Context context, String id, int active, final SuccessListener praiseListener){
        if(context instanceof BaseActivity){
            ((BaseActivity) context).enqueue(((BaseActivity) context).createCallService(RentingService.class).praise(id, active), new RetrofitCallbackListener<BaseEntity>() {
                @Override
                public void onSuccess(Call<BaseEntity> call, BaseEntity result) {
                    praiseListener.success();
                }

                @Override
                public void onError(String msg) {

                }
            });
        }
    }

    //评论
    public static void comment(final Context context, String id, String msgId, String msgContent, String toUserId, String type, final ActionResultListener praiseListener){
        if(context instanceof  BaseActivity){
            ((BaseActivity) context).enqueue(((BaseActivity) context).createCallService(RentingService.class).comment(type, id, msgId, msgContent, toUserId, null), new RetrofitCallbackListener<BaseEntity>() {
                @Override
                public void onSuccess(Call<BaseEntity> call, BaseEntity result) {
                    praiseListener.success();
                }

                @Override
                public void onError(String msg) {

                }
            });
        }
    }

    //删除评论
    public static void delComment(Context context,String id,final SuccessListener praiseListener){
        if(context instanceof BaseActivity){
            ((BaseActivity) context).enqueue(((BaseActivity) context).createCallService(RentingService.class).delComment(id), new RetrofitCallbackListener<BaseEntity>() {
                @Override
                public void onSuccess(Call<BaseEntity> call, BaseEntity result) {
                    praiseListener.success();
                }

                @Override
                public void onError(String msg) {

                }
            });
        }
    }

    //删除邻里记录
    public static void delCircle(Context context,String id,final SuccessListener praiseListener){
        if(context instanceof BaseActivity){
            ((BaseActivity) context).enqueue(((BaseActivity) context).createCallService(RentingService.class).delCircle(id), new RetrofitCallbackListener<BaseEntity>() {
                @Override
                public void onSuccess(Call<BaseEntity> call, BaseEntity result) {
                    praiseListener.success();
                }

                @Override
                public void onError(String msg) {

                }
            });
        }
    }

}
